import time
from water_tank import WaterTank
from event_handler import Event


def complex_test():
    """复杂测试用例"""
    tank = WaterTank()

    # 启动水箱
    tank.trigger(Event.START)

    # 水箱加水，检测到水，且温度 < 20°，进入加热状态
    tank.trigger(Event.WATER_DETECTED)

    # 加热过程
    tank.increase_temperature(10)
    tank.increase_temperature(10)

    # 温度 >= 100°，关闭电源
    tank.increase_temperature(80)
    tank.trigger(Event.TEMP_ABOVE_100)

    # 模拟温度降低，检查是否返回 Idle 状态
    tank.decrease_temperature(85)
    tank.trigger(Event.WATER_DETECTED)

    # 模拟晚上23:00，进入休眠模式
    tank.trigger(Event.TIME_23)

    # 模拟早上7:00，退出休眠模式
    time.sleep(2)  # 模拟时间经过
    tank.trigger(Event.TIME_7)

    # 模拟水箱烧坏并维修
    tank.trigger(Event.BURNED_OUT)
    tank.trigger(Event.MAINTENANCE)
    tank.trigger(Event.REPAIRED)

if __name__ == "__main__":
    complex_test()

